package com.springboot.shiyan2.demo;

import org.springframework.boot.CommandLineRunner;
import org.springframework.core.env.Environment;
import java.util.Objects;
@SuppressWarnings("unused")
public class myCommandLineRunner implements CommandLineRunner {

    Environment env;

    //使用构造方法注入Environment
    public myCommandLineRunner(Environment env) {
        this.env = env;
    }


    @Override
    public void run(String... args) throws Exception {
        System.out.println("利用springboot自动装配的CommandLineRunner");
        System.out.println("随机生成一个字符串：".concat(Objects.requireNonNull(env.getProperty("random."))));

    }
}
